<template>
	<view class="box">
		<view class="tou top fixed" :style="'padding-top:' + statusBarHeight1 + 'px'">
			<image @click="fanhui" class="image1" src="https://pic.bangbangtongcheng.com/static/fanhui_bai.png" />
			<!-- #ifndef MP-WEIXIN -->
			贷款计算器
			<!-- #endif -->
			<!-- #ifdef MP-WEIXIN -->
			<text style="position: absolute;left:50%;transform: translateX(-50%);">贷款计算器</text>
			<!-- #endif -->
		</view>
		<view>
			<view v-show="butText">
				<!-- 计算器 -->
				<view class="daikuanLi">
					<view :class="loanType == '组合贷款' ? 'left left1' : 'left'">贷款方式</view>
					<view :class="loanType == '组合贷款' ? 'right right1' : 'right'">
						<picker @change="PickerChange" :value="typeIndex3" :range="options">
							<view class="picker">{{ options[typeIndex3] }}</view>
						</picker>
						<p class="jian"></p>
					</view>
				</view>
				<view v-if="loanType == '商业贷款'">
					<view class="daikuanLi">
						<view class="left">贷款类型</view>
						<view class="right" style="border: 0">
							<radio-group class="radioList" @change="leixing" data-type="1">
								<label class="radio">
									<radio value="1" checked="true" />
									<span style="vertical-align: middle; font-size: 26rpx">等额本金</span>
								</label>
								<label class="radio">
									<radio value="2" />
									<span style="vertical-align: middle; font-size: 26rpx">等额本息</span>
								</label>
							</radio-group>
						</view>
					</view>
					<view class="daikuanLi">
						<view class="left">
							<span style="color: red">*</span> 贷款金额(万元)
						</view>
						<view class="right">
							<input type="number" v-model="commercialLoans.totalPrice" placeholder="请填写贷款金额" />
						</view>
					</view>
					<view class="daikuanLi">
						<view class="left">
							<span style="color: red">*</span> 期限(年)
						</view>
						<view class="right">
							<picker @change="nianChange" data-type="1" :value="nianIndex1"
								:range="accumulationFund.year_list">
								<view class="picker">
									{{
                  accumulationFund.year_list[nianIndex1]
                  }}
								</view>
							</picker>
							<p class="jian"></p>
						</view>
					</view>
					<view class="daikuanLi">
						<view class="left">
							<span style="color: red">*</span> 利率(%)
						</view>
						<view class="right">
							<picker @change="lixiChange" data-type="1" :value="lixiIndex1"
								:range="commercialLoans.interestRate_list">
								<view class="picker">
									{{
                  commercialLoans.interestRate_list[lixiIndex1]
                  }}
								</view>
							</picker>
							<p class="jian"></p>
						</view>
					</view>
				</view>
				<view v-if="loanType == '公积金贷款'">
					<view class="daikuanLi">
						<view class="left">贷款类型</view>
						<view class="right" style="border: 0">
							<radio-group class="radioList" @change="leixing" data-type="2">
								<label class="radio">
									<radio value="1" checked="true" />
									<span style="vertical-align: middle; font-size: 26rpx">等额本金</span>
								</label>
								<label class="radio">
									<radio value="2" />
									<span style="vertical-align: middle; font-size: 26rpx">等额本息</span>
								</label>
							</radio-group>
						</view>
					</view>
					<view class="daikuanLi">
						<view class="left">
							<span style="color: red">*</span> 贷款金额(万元)
						</view>
						<view class="right">
							<input type="number" v-model="accumulationFund.totalPrice" placeholder="请填写贷款金额" />
						</view>
					</view>
					<view class="daikuanLi">
						<view class="left">
							<span style="color: red">*</span> 期限(年)
						</view>
						<view class="right">
							<picker @change="nianChange" data-type="2" :value="nianIndex2"
								:range="accumulationFund.year_list">
								<view class="picker">
									{{
                  accumulationFund.year_list[nianIndex2]
                  }}
								</view>
							</picker>
							<p class="jian"></p>
						</view>
					</view>
					<view class="daikuanLi">
						<view class="left">
							<span style="color: red">*</span> 利率(%)
						</view>
						<view class="right">
							<picker @change="lixiChange" data-type="2" :value="lixiIndex2"
								:range="accumulationFund.interestRate_list">
								<view class="picker">
									{{
                  accumulationFund.interestRate_list[lixiIndex2]
                  }}
								</view>
							</picker>
							<p class="jian"></p>
						</view>
					</view>
				</view>
				<view v-if="loanType == '组合贷款'">
					<view class="daikuanLi">
						<view class="left left1">贷款类型</view>
						<view class="right right1" style="padding-left: 0rpx; width: 380rpx; border: 0">
							<radio-group class="radioList" @change="leixing" data-type="3">
								<label class="radio">
									<radio value="1" checked="true" />
									<span style="vertical-align: middle; font-size: 26rpx">等额本金</span>
								</label>
								<label class="radio">
									<radio value="2" />
									<span style="vertical-align: middle; font-size: 26rpx">等额本息</span>
								</label>
							</radio-group>
						</view>
					</view>
					<view class="daikuanLi">
						<view class="left left1">
							<span style="color: red">*</span> 商贷贷款金额(万元)
						</view>
						<view class="right right1">
							<input type="number" v-model="combinationLoan.zhs_Price" placeholder="请填写商贷贷款金额" />
						</view>
					</view>
					<view class="daikuanLi">
						<view class="left left1">
							<span style="color: red">*</span> 商贷利率(%)
						</view>
						<view class="right right1">
							<picker @change="lixiChange" data-type="3" :value="lixiIndex3"
								:range="combinationLoan.zhs_interestRate_list">
								<view class="picker">
									{{
                  combinationLoan.zhs_interestRate_list[lixiIndex3]
                  }}
								</view>
							</picker>
							<p class="jian"></p>
						</view>
					</view>
					<view class="daikuanLi">
						<view class="left left1">
							<span style="color: red">*</span> 公积金贷款金额(万元)
						</view>
						<view class="right right1">
							<input type="number" v-model="combinationLoan.zhg_Price" placeholder="请填写公积金贷款金额" />
						</view>
					</view>
					<view class="daikuanLi">
						<view class="left left1">
							<span style="color: red">*</span> 公积金利率(%)
						</view>
						<view class="right right1">
							<picker @change="lixiChange" data-type="4" :value="lixiIndex4"
								:range="combinationLoan.zhg_interestRate_list">
								<view class="picker">
									{{
                  combinationLoan.zhg_interestRate_list[lixiIndex4]
                  }}
								</view>
							</picker>
							<p class="jian"></p>
						</view>
					</view>
					<view class="daikuanLi">
						<view class="left left1">
							<span style="color: red">*</span>期限(年)
						</view>
						<view class="right right1">
							<picker @change="nianChange" data-type="3" :value="nianIndex3"
								:range="combinationLoan.year_list[nianIndex3]">
								<view class="picker">
									{{
                  combinationLoan.year_list[nianIndex3]
                  }}
								</view>
							</picker>
							<p class="jian"></p>
						</view>
					</view>
				</view>
			</view>
			<view v-show="!butText">
				<!-- 结果表格 -->
				<view class="jieguo">
					<view class="jieguo_tou">
						<p class="p1">{{ tableData.list[0].zong }}</p>
						<p class="p2">{{ denge == 1 ? "首月还款(元)" : "每月还款(元)" }}</p>
						<view class="bot">
							<view>
								<p>利息总额(元)</p>
								<p style="opacity: 1">{{ tableData.li }}</p>
							</view>
							<view>
								<p>还款期数</p>
								<p style="opacity: 1">{{ tableData.list.length }}</p>
							</view>
							<view>
								<p>还款总额(元)</p>
								<p style="opacity: 1">{{ tableData.zong }}</p>
							</view>
						</view>
					</view>
					<view class="biao">
						<view class="biaotou">
							<view>还款期数</view>
							<view>月供总额</view>
							<view>还款本金</view>
							<view>月供利息</view>
						</view>
						<view class="biaoList">
							<view class="li" v-for="(item, index) in tableData.list" :key="index">
								<view>{{ item.index }}</view>
								<view>{{ item.zong }}</view>
								<view>{{ item.ben }}</view>
								<view>{{ item.li }}</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="jisuan"  @click="submitCal">
			{{
      butText ? "开始计算" : "返回计算"
      }}
		</view>
		<uniBall></uniBall>
	</view>
</template>

<script>
	//#ifdef H5
	import wxshare from "../utils/index.js";
	//#endif
	import {
		mapGetters
	} from "vuex";
	import * as CFHL from "../components/calculatorForHouseLoan";
	export default {
		computed: {
			...mapGetters(["statusBarHeight1", "userinfo"])
		},
		filters: {
			nums(val) {
				return val.toFixed(2);
			}
		},
		data() {
			const totalPrice = (rule, value, callback) => {
				// 判断手机号是否正确
				if (value) {
					value = parseInt(value);
					let regTest = /^0/;
					if (regTest.test(value) || isNaN(value)) {
						callback(new Error("请输入正整数"));
					} else {
						if (value * 1 > 200000) {
							// value = 200000;
							callback(new Error("请不要输入超过200000万元"));
						} else {
							callback();
						}
					}
				} else {
					callback(new Error("请输入贷款金额"));
				}
			};
			return {
				data: [],
				formWidth: 0,
				tuLiatWidth: 0,
				daikuan: 1,
				butText: true,
				denge: 1,
				options: ["商业贷款", "公积金贷款", "组合贷款"],
				typeIndex3: 0,
				loanType: "商业贷款",
				nianIndex1: 29,
				nianIndex2: 29,
				nianIndex3: 29,
				lixiIndex1: 0,
				lixiIndex2: 0,
				lixiIndex3: 0,
				lixiIndex4: 0,
				imgUrl: this.$imgSrc,
				tableData: {
					li: "",
					zong: "",
					list: [{
						index: "",
						zong: "",
						ben: "",
						li: ""
					}]
				},
				commercialLoans: {
					monthlySupply: 0, //月供
					grossInterest: 0, //总利息
					totalRepayment: 0, //还款总额
					totalPrice: "", //贷款金额
					loanType: "1", //商贷贷款类型 1等额本金 2等额本息
					year: "30", //商贷期限
					year_list: [], //商贷期限列表
					interestRate: "", //商贷默认利率
					interestRate_index: 0,
					interestRate_list: [
						
					] //商贷利率列表
				},
				accumulationFund: {
					monthlySupply: 0, //月供
					grossInterest: 0, //总利息
					totalRepayment: 0, //还款总额
					totalPrice: "", //贷款金额
					loanType: "1", //公积金贷款类型 1等额本金 2等额本息
					year: "30", //公积金期限
					year_list: [], //公积金期限列表
					interestRate: "", //公积金默认利率
					interestRate_index: 0,
					interestRate_list: [] //公积金利率列表
				},
				combinationLoan: {
					monthlySupply: 0, //月供
					grossInterest: 0, //总利息
					totalRepayment: 0, //还款总额
					zhs_Price: "",
					zhg_Price: "",
					loanType: "1", //组合贷贷款类型 1等额本金 2等额本息
					year: "30", //组合期限
					year_list: [], //组合期限列表
					zhs_interestRate: "", //商贷默认利率
					zhs_interestRate_index: 0,
					zhs_interestRate_list: [
						
					], //商贷利率列表
					zhg_interestRate: "", //公积金默认利率
					zhg_interestRate_index: 0,
					zhg_interestRate_list: [] //公积金利率列表
				},
				rules: {
					totalPrice: [{
							required: true,
							message: "请输入贷款金额",
							trigger: "blur"
						},
						{
							validator: totalPrice,
							trigger: "blur"
						}
					],
					year: [{
						required: true,
						message: "请选择期限",
						trigger: "change"
					}],
					interestRate: [{
						required: true,
						message: "请选择利率",
						trigger: "change"
					}]
				},
				rulesThree: {
					zhs_Price: [{
							required: true,
							message: "请输入贷款金额",
							trigger: "blur"
						},
						{
							validator: totalPrice,
							trigger: "blur"
						}
					],
					zhg_Price: [{
							required: true,
							message: "请输入贷款金额",
							trigger: "blur"
						},
						{
							validator: totalPrice,
							trigger: "blur"
						}
					],
					year: [{
						required: true,
						message: "请选择期限",
						trigger: "change"
					}],
					zhs_interestRate: [{
						required: true,
						message: "请选择商贷利率",
						trigger: "change"
					}],
					zhg_interestRate: [{
						required: true,
						message: "请选择公积金利率",
						trigger: "change"
					}]
				}
			};
		},
		mounted() {
			let contrastList = uni.getStorageSync("contrast");
			this.tuLiatWidth = contrastList.length * 280;
			this.formWidth = contrastList.length * 280 + 142;
			for (let i = 0; i < 30; i++) {
				this.commercialLoans.year_list.push(i + 1);
				this.accumulationFund.year_list.push(i + 1);
				this.combinationLoan.year_list.push(i + 1);
			}
			/* #ifdef H5 */
			this.jinzhi();
			/* #endif */
			if (contrastList.length > 0) {
				for (var i = 0; i < contrastList.length; i++) {
					let contrast1 = contrastList[i];
					if (contrast1.id) {
						if (contrast1.hasOwnProperty("floor")) {
							let floor = contrast1.floor.split(",");
							contrast1.lcType = floor[0];
							if (floor[0] == 1) {
								contrast1.lou1 = floor[1];
								contrast1.lou3 = floor[2];
							} else if (floor[0] == 2) {
								contrast1.lou1 = floor[1];
								contrast1.lou2 = floor[2];
								contrast1.lou3 = floor[3];
							} else if (floor[0] == 3) {
								data.lou3 = floor[1];
							}
						}
						if (contrast1.houseImage) {
							contrast1.house_image = contrast1.houseImage.split("|")[0];
						}
						if (contrast1.houseTypeImage) {
							contrast1.house_type_image = contrast1.houseTypeImage.split("|")[0];
						}
						contrast1.AREA = contrast1.area;
						this.data.push(contrast1);
					}
				}
			}
		},
		onLoad() {
			this.interestRate(1)
		},
		onShow() {
			this.data = this.data;
		},
		methods: {
			clickImg(url) {
				wx.previewImage({
					urls: [url], //需要预览的图片http链接列表，多张的时候，url直接写在后面就行了
					current: "", // 当前显示图片的http链接，默认是第一个
					success: function(res) {},
					fail: function(res) {},
					complete: function(res) {}
				});
			},
			quchu(index) {
				let contrastList = uni.getStorageSync("contrast");
				for (var i = 0; i < contrastList.length; i++) {
					if (contrastList[i].id == this.data[index].id) {
						contrastList.splice(i, 1);
						uni.setStorageSync("contrast", contrastList);
					}
				}
				this.data.splice(index, 1);
				this.tuLiatWidth = this.data.length * 280;
				this.formWidth = this.data.length * 280 + 142;
			},
			fanhui() {
				uni.navigateBack({
					delta: 1
				});
			},

			PickerChange(e) {
				//选择贷款方式
				if (e.target.value == 0) {
					this.typeIndex3 = 0;
					this.loanType = "商业贷款";
					this.ruleForm = "ruleForm1";
					this.interestRate(1)
				} else if (e.target.value == 1) {
					this.typeIndex3 = 1;
					this.loanType = "公积金贷款";
					this.ruleForm = "ruleForm2";
					this.interestRate(2)
				} else if (e.target.value == 2) {
					this.typeIndex3 = 2;
					this.loanType = "组合贷款";
					this.ruleForm = "ruleForm3";
					this.interestRate(3)
				}
			},
			// 获取贷款利率
			interestRate(type){
				this.$myRequest
					.get("/mob/lendingRates/getlendingRate", {
						loanType:type
					})
					.then(res => {
						if (type==1) {
							res.lendingRates.forEach(v=>{
								this.commercialLoans.interestRate_list.push(v.loanNum+"%")
							})
							this.commercialLoans.interestRate=res.lendingRates[0].loanNum+"%"
						}else if(type==2){
							res.lendingRates.forEach(v=>{
								this.accumulationFund.interestRate_list.push(v.loanNum+"%")
							})
							this.accumulationFund.interestRate=res.lendingRates[0].loanNum+"%"
						}else{
							res.lendingRates.forEach(v=>{
								if (v.loanType==1) {
									this.combinationLoan.zhs_interestRate_list.push(v.loanNum+"%")
									if(!this.combinationLoan.zhs_interestRate){
										this.combinationLoan.zhs_interestRate=v.loanNum+"%"
									}
								}else{
									this.combinationLoan.zhg_interestRate_list.push(v.loanNum+"%")
									if(!this.combinationLoan.zhg_interestRate){
										this.combinationLoan.zhg_interestRate=v.loanNum+"%"
									}
								}
							})
						}
					});
			},

			leixing(e) {
				//贷款类型
				if (e.target.dataset.type == 1) {
					this.commercialLoans.loanType = e.target.value;
				} else if (e.target.dataset.type == 2) {
					this.accumulationFund.loanType = e.target.value;
				} else if (e.target.dataset.type == 3) {
					this.combinationLoan.loanType = e.target.value;
				}
			},
			nianChange(e) {
				//年限

				if (e.target.dataset.type == 1) {
					this.nianIndex1 = e.target.value;
					this.commercialLoans.year = this.commercialLoans.year_list[
						e.target.value
					];
				} else if (e.target.dataset.type == 2) {
					this.nianIndex2 = e.target.value;
					this.accumulationFund.year = this.accumulationFund.year_list[
						e.target.value
					];
				} else if (e.target.dataset.type == 3) {
					this.nianIndex3 = e.target.value;
					this.combinationLoan.year = this.combinationLoan.year_list[
						e.target.value
					];
				}

				this.year_picker(e.target.value + 1);
			},
			year_picker(e) {
				//选择年份的时候切换利率列表
				var arr1 = [],
					arr2 = [];
				if (this.loanType == "商业贷款") {
					//商贷期限
					this.commercialLoans.year = e;
					if (this.commercialLoans.year == 1) {
						arr1 = [
							"4.35%",
							"3.045%",
							"3.262%",
							"3.48%",
							"3.698%",
							"3.915%",
							"4.132%",
							"4.568%",
							"4.785%",
							"5.22%",
							"5.655%"
						];
					} else if (
						this.commercialLoans.year > 1 &&
						this.commercialLoans.year <= 5
					) {
						arr1 = [
							"4.75%",
							"3.325%",
							"3.563%",
							"3.8%",
							"4.037%",
							"4.275%",
							"4.513%",
							"4.955%",
							"5.225%",
							"5.7%",
							"6.175%"
						];
					} else {
						arr1 = [
							"4.9%",
							"3.43%",
							"3.675%",
							"3.92%",
							"4.17%",
							"4.41%",
							"4.66%",
							"5.15%",
							"5.25%",
							"5.39%",
							"5.88%",
							"6.37%"
						];
					}
					this.commercialLoans.interestRate_list = arr1;
					this.commercialLoans.interestRate =
						arr1[this.commercialLoans.interestRate_index];
				} else if (this.loanType == "公积金贷款") {
					//公积金期限
					this.accumulationFund.year = e;
					if (this.accumulationFund.year <= 5) {
						arr2 = ["2.75%", "3.025%", "3.3%", "3.575%"];
					} else {
						arr2 = ["3.25%", "3.58%", "3.90%", "4.23%"];
					}
					this.accumulationFund.interestRate_list = arr2;
					this.accumulationFund.interestRate =
						arr2[this.accumulationFund.interestRate_index];
				} else if (this.loanType == "组合贷款") {
					//组合贷期限
					this.combinationLoan.year = e;
					if (this.combinationLoan.year == 1) {
						arr1 = [
							"4.35%",
							"3.045%",
							"3.262%",
							"3.48%",
							"3.698%",
							"3.915%",
							"4.132%",
							"4.568%",
							"4.785%",
							"5.22%",
							"5.655%"
						];
						arr2 = ["2.75%", "3.025%", "3.3%", "3.575%"];
					} else if (
						this.combinationLoan.year > 1 &&
						this.combinationLoan.year <= 5
					) {
						arr1 = [
							"4.75%",
							"3.325%",
							"3.563%",
							"3.8%",
							"4.037%",
							"4.275%",
							"4.513%",
							"4.955%",
							"5.225%",
							"5.7%",
							"6.175%"
						];
						arr2 = ["2.75%", "3.025%", "3.3%", "3.575%"];
					} else {
						arr1 = [
							"4.9%",
							"3.43%",
							"3.675%",
							"3.92%",
							"4.17%",
							"4.41%",
							"4.66%",
							"5.15%",
							"5.25%",
							"5.39%",
							"5.88%",
							"6.37%"
						];
						arr2 = ["3.25%", "3.58%", "3.90%", "4.23%"];
					}
					this.combinationLoan.zhs_interestRate_list = arr1;
					this.combinationLoan.zhs_interestRate =
						arr1[this.combinationLoan.zhs_interestRate_index];
					this.combinationLoan.zhg_interestRate_list = arr2;
					this.combinationLoan.zhg_interestRate =
						arr2[this.combinationLoan.zhg_interestRate_index];
				}
			},
			lixiChange(e) {
				if (e.target.dataset.type == 1) {
					this.lixiIndex1 = e.target.value;
					this.commercialLoans.interestRate = this.commercialLoans.interestRate_list[
						e.target.value
					];
				} else if (e.target.dataset.type == 2) {
					this.lixiIndex2 = e.target.value;
					this.accumulationFund.interestRate = this.accumulationFund.interestRate_list[
						e.target.value
					];
				} else if (e.target.dataset.type == 3) {
					this.lixiIndex3 = e.target.value;
					this.combinationLoan.zhs_interestRate = this.combinationLoan.zhs_interestRate_list[
						e.target.value
					];
				} else if (e.target.dataset.type == 4) {
					this.lixiIndex4 = e.target.value;
					this.combinationLoan.zhg_interestRate = this.combinationLoan.zhg_interestRate_list[
						e.target.value
					];
				}
			},
			rage_picker(e, type) {
				if (this.loanType == "商业贷款") {
					//商贷利率
					this.commercialLoans.interestRate = e;
					this.commercialLoans.interestRate_index = this.commercialLoans.interestRate_list.findIndex(
						r => {
							return r == e;
						}
					);
				} else if (this.loanType == "公积金贷款") {
					//公积金利率
					this.accumulationFund.interestRate = e;
					this.accumulationFund.interestRate_index = this.commercialLoans.interestRate_index.findIndex(
						r => {
							return r == e;
						}
					);
				} else if (this.loanType == "组合贷款") {
					if (type == "commercialLoans_interestRate") {
						//组合贷商贷利率
						this.combinationLoan.zhs_interestRate = e;
						this.combinationLoan.zhs_interestRate_index = this.commercialLoans.zhs_interestRate_index
							.findIndex(
								r => {
									return r == e;
								}
							);
					} else if (type == "accumulationFund_interestRate") {
						//组合贷公积金利率
						this.combinationLoan.zhg_interestRate = e;
						this.combinationLoan.zhg_interestRate_index = this.commercialLoans.zhg_interestRate_index
							.findIndex(
								r => {
									return r == e;
								}
							);
					}
				}
			},
			submitCal() {
				//点计算
				if (this.loanType == "商业贷款") {
					if (this.commercialLoans.totalPrice == "") {
						uni.showToast({
							title: "金额不能为空",
							duration: 2000,
							icon: "error"
						});
						return;
					}
				} else if (this.loanType == "公积金贷款") {
					if (this.accumulationFund.totalPrice == "") {
						uni.showToast({
							title: "金额不能为空",
							duration: 2000,
							icon: "error"
						});
						return;
					}
				} else if (this.loanType == "组合贷款") {
					if (this.combinationLoan.zhs_Price == "") {
						uni.showToast({
							title: "金额不能为空",
							duration: 2000,
							icon: "error"
						});
						return;
					}
					if (this.combinationLoan.zhg_Price == "") {
						uni.showToast({
							title: "金额不能为空",
							duration: 2000,
							icon: "error"
						});
						return;
					}
				}
				this.butText = !this.butText;
				this.calculateLoan();
			},
			jinzhi() {
				let _this = this;
				let param = window.location.href.split("#")[0];
				uni.request({
					method: "post",
					data: {
						url: param
					},
					header: {
						"content-type": "application/x-www-form-urlencoded"
					},
					url: "https://www.bangbangtongcheng.com/conven//mob/login/getJsTicket.do",
					success(re) {
						_this.jinzhifx(re.data);
					}
				});
			},
			jinzhifx(data) {
				wxshare.config({
					debug: false, //是否打开调试
					appId: data.appId, // 公众号的唯一标识
					timestamp: data.timestamp, // 生成签名的时间戳
					nonceStr: data.nonce, // ，生成签名的随机串
					signature: data.signature, // 签名
					jsApiList: ["hideMenuItems"]
				});
				// 禁止分享
				wxshare.hideMenuItems({
					// 要隐藏的菜单项，只能隐藏“传播类”和“保护类”按钮，所有menu项见附录3
					menuList: [
						"menuItem:share:appMessage",
						"menuItem:share:timeline",
						"menuItem:share:timeline",
						"menuItem:share:qq",
						"menuItem:favorite",
						"menuItem:share:QZone",
						"menuItem:openWithSafari"
					]
				});
			},
			select(index) {
				uni.navigateTo({
					url: "/pages_my/select?type=" + index
				});
			},
			calculateLoan() {
				let commercialLoans = this.commercialLoans;
				let accumulationFund = this.accumulationFund;
				let combinationLoan = this.combinationLoan;
				if (this.loanType == "商业贷款") {
					let detail = CFHL.calculate(
						commercialLoans.totalPrice * 10000,
						commercialLoans.interestRate.replace("%", "") / 100 / 12,
						commercialLoans.year * 12
					);
					if (commercialLoans.loanType == "2") {
						this.denge = 2;
						//等额本息
						this.commercialLoans.monthlySupply = detail.repayPerMouAi;
						this.commercialLoans.grossInterest = detail.totalInterestAi;
						this.commercialLoans.totalRepayment = detail.totalRepayAi;
						this.tableData.li = detail.totalInterestAi;
						this.tableData.zong = detail.totalRepayAi;
						this.tableData.list = [];
						detail.repayPerMouObjAi.repayInterestPerMouArrAi.forEach((e, i) => {
							this.tableData.list.push({
								index: i + 1,
								zong: (
									Number(e) +
									Number(detail.repayPerMouObjAi.repayPrincipalPerMouArrAi[i])
								).toFixed(2),
								ben: Number(
									detail.repayPerMouObjAi.repayPrincipalPerMouArrAi[i]
								).toFixed(2),
								li: Number(e).toFixed(2)
							});
						});
					} else {
						this.denge = 1;
						//等额本金
						this.commercialLoans.monthlySupply = detail.repayPerMouthAp;
						this.commercialLoans.grossInterest = detail.totalInterestAp;
						this.commercialLoans.totalRepayment = detail.totalRepayPriceAp;
						this.tableData.li = detail.totalInterestAp;
						this.tableData.zong = detail.totalRepayPriceAp;
						this.tableData.list = [];
						detail.repayPerMouObjAp.repayPerMouPriceArrAp.forEach((e, i) => {
							this.tableData.list.push({
								index: i + 1,
								zong: Number(e).toFixed(2),
								ben: (
									Number(e) -
									Number(detail.repayPerMouObjAp.repayInterestPerMouArrAp[i])
								).toFixed(2),
								li: Number(
									detail.repayPerMouObjAp.repayInterestPerMouArrAp[i]
								).toFixed(2)
							});
						});
					}
					console.log(detail);
				} else if (this.loanType == "公积金贷款") {
					let detail = CFHL.calculate(
						accumulationFund.totalPrice * 10000,
						accumulationFund.interestRate.replace("%", "") / 100 / 12,
						accumulationFund.year * 12
					);
					console.log(detail, 2);
					if (accumulationFund.loanType == "2") {
						this.denge = 2;
						//等额本息
						this.accumulationFund.monthlySupply = detail.repayPerMouAi;
						this.accumulationFund.grossInterest = detail.totalInterestAi;
						this.accumulationFund.totalRepayment = detail.totalRepayAi;
						this.tableData.li = detail.totalInterestAi;
						this.tableData.zong = detail.totalRepayAi;
						this.tableData.list = [];
						detail.repayPerMouObjAi.repayInterestPerMouArrAi.forEach((e, i) => {
							this.tableData.list.push({
								index: i + 1,
								zong: (
									Number(e) +
									Number(detail.repayPerMouObjAi.repayPrincipalPerMouArrAi[i])
								).toFixed(2),
								ben: Number(
									detail.repayPerMouObjAi.repayPrincipalPerMouArrAi[i]
								).toFixed(2),
								li: Number(e).toFixed(2)
							});
						});
					} else {
						this.denge = 1;
						//等额本金
						this.accumulationFund.monthlySupply = detail.repayPerMouthAp;
						this.accumulationFund.grossInterest = detail.totalInterestAp;
						this.accumulationFund.totalRepayment = detail.totalRepayPriceAp;
						this.tableData.li = detail.totalInterestAp;
						this.tableData.zong = detail.totalRepayPriceAp;
						this.tableData.list = [];
						detail.repayPerMouObjAp.repayPerMouPriceArrAp.forEach((e, i) => {
							this.tableData.list.push({
								index: i + 1,
								zong: Number(e).toFixed(2),
								ben: (
									Number(e) -
									Number(detail.repayPerMouObjAp.repayInterestPerMouArrAp[i])
								).toFixed(2),
								li: Number(
									detail.repayPerMouObjAp.repayInterestPerMouArrAp[i]
								).toFixed(2)
							});
						});
					}
				} else if (this.loanType == "组合贷款") {
					//商贷
					var detail1 = CFHL.calculate(
						combinationLoan.zhs_Price * 10000,
						combinationLoan.zhs_interestRate.replace("%", "") / 100 / 12,
						combinationLoan.year * 12
					);
					//公积金
					var detail2 = CFHL.calculate(
						combinationLoan.zhg_Price * 10000,
						combinationLoan.zhg_interestRate.replace("%", "") / 100 / 12,
						combinationLoan.year * 12
					);
					console.log(detail1, detail2);
					if (combinationLoan.loanType == "2") {
						this.denge = 2;
						//等额本息
						this.combinationLoan.monthlySupply =
							detail1.repayPerMouAi * 1 + detail2.repayPerMouAi * 1;
						this.combinationLoan.grossInterest =
							detail1.totalInterestAi * 1 + detail2.totalInterestAi * 1;
						this.combinationLoan.totalRepayment =
							detail1.totalRepayAi * 1 + detail2.totalRepayAi * 1;

						this.tableData.li =
							Number(detail1.totalInterestAi) - -Number(detail2.totalInterestAi);
						this.tableData.zong =
							Number(detail1.totalRepayAi) - -Number(detail2.totalRepayAi);
						this.tableData.list = [];
						detail1.repayPerMouObjAi.repayInterestPerMouArrAi.forEach((e, i) => {
							this.tableData.list.push({
								index: i + 1,
								zong: (
									Number(e) +
									Number(detail1.repayPerMouObjAi.repayPrincipalPerMouArrAi[i]) +
									Number(detail2.repayPerMouObjAi.repayInterestPerMouArrAi[i]) +
									Number(detail2.repayPerMouObjAi.repayPrincipalPerMouArrAi[i])
								).toFixed(2),

								ben: (
									Number(detail1.repayPerMouObjAi.repayPrincipalPerMouArrAi[i]) +
									Number(detail2.repayPerMouObjAi.repayPrincipalPerMouArrAi[i])
								).toFixed(2),

								li: (
									Number(e) -
									-detail2.repayPerMouObjAi.repayInterestPerMouArrAi[i]
								).toFixed(2)
							});
						});
					} else {
						this.denge = 1;
						//等额本金
						this.combinationLoan.monthlySupply =
							detail1.repayPerMouthAp * 1 + detail2.repayPerMouthAp * 1;
						this.combinationLoan.grossInterest =
							detail1.totalInterestAp * 1 + detail2.totalInterestAp * 1;
						this.combinationLoan.totalRepayment =
							detail1.totalRepayPriceAp * 1 + detail2.totalRepayPriceAp * 1;

						this.tableData.li =
							Number(detail1.totalInterestAp) - -Number(detail2.totalInterestAp);
						this.tableData.zong =
							Number(detail1.totalRepayPriceAp) -
							-Number(detail2.totalRepayPriceAp);
						this.tableData.list = [];
						detail1.repayPerMouObjAp.repayPerMouPriceArrAp.forEach((e, i) => {
							this.tableData.list.push({
								index: i + 1,
								zong: (
									Number(e) +
									Number(detail2.repayPerMouObjAp.repayPerMouPriceArrAp[i])
								).toFixed(2),

								ben: (
									Number(e) -
									Number(detail1.repayPerMouObjAp.repayInterestPerMouArrAp[i]) +
									(Number(detail2.repayPerMouObjAp.repayPerMouPriceArrAp[i]) -
										Number(detail2.repayPerMouObjAp.repayInterestPerMouArrAp[i]))
								).toFixed(2),

								li: (
									Number(detail1.repayPerMouObjAp.repayInterestPerMouArrAp[i]) +
									Number(detail2.repayPerMouObjAp.repayInterestPerMouArrAp[i])
								).toFixed(2)
							});
						});
					}
				}
				console.log(this.tableData);
			}
		}
	};
</script>

<style lang="less" scoped>
	.jieguo {
		width: 690rpx;
		margin-left: 30rpx;
		margin-top: 20rpx;

		.jieguo_tou {
			position: relative;
			width: 100%;
			height: 254rpx;
			background: linear-gradient(133deg,
					rgba(100, 182, 168, 0.62) 0%,
					#64b6a8 100%);
			border-radius: 6rpx;
			padding-top: 32rpx;

			.p1 {
				text-align: center;
				font-weight: 600;
				font-size: 38rpx;
				color: #fff;
			}

			.p2 {
				text-align: center;
				font-size: 24rpx;
				color: #fff;
				opacity: 0.7;
			}

			.bot {
				position: absolute;
				width: 100%;
				bottom: 22rpx;

				>view {
					display: inline-block;
					width: 33.33%;

					p {
						display: block;
						text-align: center;
						font-size: 28rpx;
						color: #fff;
						opacity: 0.7;
					}
				}
			}
		}

		.biao {
			width: 690rpx;
			border: 2rpx solid #e0e0e0;
			margin-top: 20rpx;

			.biaotou {
				width: 100%;
				top: 0;

				view {
					display: inline-block;
					width: 25%;
					height: 80rpx;
					line-height: 80rpx;
					text-align: center;
					font-size: 28rpx;
					color: #333;
					font-weight: 600;
				}
			}

			.biaoList {
				width: 100%;
				height: 740rpx;
				overflow-y: auto;

				.li {
					view {
						display: inline-block;
						width: 25%;
						height: 60rpx;
						line-height: 60rpx;
						text-align: center;
						font-size: 28rpx;
						color: #333;
					}
				}
			}
		}
	}

	.jisuan {
		position: fixed;
		width: 670rpx;
		height: 80rpx;
		text-align: center;
		line-height: 80rpx;
		color: #fff;
		background-color: #64b6a8;
		border-radius: 40rpx;
		bottom: 40rpx;
		left: 50%;
		font-size: 30rpx;
		transform: translateX(-50%);
	}

	.daikuanLi {
		margin-top: 50rpx;

		.left {
			display: inline-block;
			width: 200rpx;
			font-size: 28rpx;
			color: #000;
			margin-bottom: 60rpx;
			margin-left: 50rpx;
			margin-right: 20rpx;
		}

		.right {
			position: relative;
			display: inline-block;
			vertical-align: middle;
			box-sizing: border-box;
			width: 384rpx;
			height: 60rpx;
			padding-top: 8rpx;
			padding-left: 18rpx;
			border: 2rpx solid #d0d0d0;

			.jian {
				position: absolute;
				top: 22rpx;
				right: 30rpx;
				border-color: #999 rgba(0, 0, 0, 0) rgba(0, 0, 0, 0) rgba(0, 0, 0, 0);
				border-style: solid;
				border-width: 14rpx 8rpx 0rpx 8rpx;
				height: 0;
				width: 0;
			}
		}

		.left1 {
			width: 290rpx;
		}

		.right1 {
			width: 340rpx;
		}
	}

	.tuLiat {
		width: 100%;
		margin-top: 50rpx;
		overflow: auto;

		.div {
			display: flex;
			align-items: center;

			// height: 288rpx;
			.li {
				position: relative;
				display: inline-block;
				width: 240rpx;
				height: 270rpx;
				margin-top: 18rpx;
				margin-left: 18rpx;
				margin-right: 24rpx;
				border: 2rpx solid #d0d0d0;
				box-sizing: border-box;
				padding: 12rpx 8rpx;


				.guan {
					position: absolute;
					top: -20rpx;
					right: -20rpx;
					width: 36rpx;
					height: 36rpx;
					background-color: #999999;
					color: #fff;
					text-align: center;
					line-height: 36rpx;
					border-radius: 50%;
				}

				image {
					background-color: #f8f8f8;
					width: 220rpx;
					height: 146rpx;
				}

				.p1 {
					width: 220rpx;
					font-size: 24rpx;
					margin-top: 12rpx;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}

				.p2 {
					font-size: 26rpx;
					font-weight: 600;
					color: red;
					margin-top: 12rpx;
				}
			}
		}

		.name {
			font-size: 30rpx;
			font-weight: 600;
			color: #64b6a8;
			margin-left: 30rpx;
			margin-top: 40rpx;
			margin-bottom: 26rpx;
		}

		.form {
			display: inline-block;
			margin-left: 30rpx;
			border-left: 2rpx solid #e0e0e0;
			border-bottom: 2rpx solid #e0e0e0;

			.hang {
				display: inline-block;
				vertical-align: top;

				view {
					box-sizing: border-box;
					width: 140rpx;
					height: 78rpx;
					font-size: 24rpx;
					font-weight: 600;
					border-right: 2rpx solid #e0e0e0;
					border-top: 2rpx solid #e0e0e0;
					padding-top: 24rpx;
					text-align: center;
				}
			}

			.hang1 {
				display: inline-block;
				vertical-align: top;

				view {
					box-sizing: border-box;
					width: 280rpx;
					height: 78rpx;
					font-size: 24rpx;
					border-right: 2rpx solid #e0e0e0;
					border-top: 2rpx solid #e0e0e0;
					padding: 20rpx 30rpx;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;

					image {
						background-color: #f8f8f8;

						width: 220rpx;
						height: 140rpx;
					}
				}
			}
		}
	}

	.box {
		// position: absolute;
		width: 100%;
		// top: 0;
		// bottom: 0;
		color: #333;
		background-color: #fff;
		min-height: 100vh;
	}

	.tou {
		position: relative;
		width: 100%;
		// height: 88rpx;
		text-align: center;
		/* #ifdef MP-WEIXIN */
		text-align: left;
		display: flex;
		align-items: center;
		/* #endif */
		line-height: 88rpx;
		font-size: 36rpx;
		color: #fff;
		background-color: #64b6a8;
	
		.image1 {
			position: absolute;
			width: 32rpx;
			height: 32rpx;
			// top: 116rpx;
			left: 30rpx; 
		}
	
		.image2 {
			position: absolute;
			width: 56rpx;
			height: 56rpx;
			bottom: 16rpx!important;
			right: 30rpx;
			/* #ifdef MP-WEIXIN */
			position: initial;
			margin-left: auto;
			margin-right: 200rpx;
			/* #endif */
		}
	}

	.radio {
		font-size: 34rpx;
		margin-right: 20rpx;

		radio {
			margin-right: 10rpx;
		}
	}

	/deep/uni-radio .wx-radio-input,
	/deep/uni-radio .uni-radio-input {
		width: 36rpx;
		height: 36rpx;
	}

	/deep/.uni-radio-input-checked {
		background-color: #64b6a8 !important;
		border-color: #64b6a8 !important;
	}

	/deep/uni-radio .uni-radio-input {
		background-color: rgba(0, 0, 0, 0);
		border: 2rpx solid #999;
	}

	/deep/.uni-radio-input-checked {
		background-color: #64b6a8 !important;
		border: 2rpx solid #64b6a8 !important;
	}

	/deep/ uni-radio::before {
		font-size: 32rpx;
		margin-top: -16rpx;
		right: 4rpx !important;
	}

	.noneT {
		display: flex;
		width: 100%;
		height: 100%;
		justify-content: center;
		align-items: center;
		color: #999;
		font-size: 40rpx;
		font-weight: bold;
	}
</style>
